package com.cn.admin.controller;

import com.alibaba.fastjson.JSONObject;
import com.cn.admin.utils.ExcelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/excel")
public class ExcelController {

    private static Logger logger = LoggerFactory.getLogger(ExcelController.class);

    @Autowired
    private ExcelUtils excelUtils;

    @PostMapping("/uploadExcel")
    public Map uploadExcel(MultipartFile file) throws Exception{

        Map map=new HashMap();

        List<List<String>> lists = excelUtils.readXls(file);

        map.put("list",lists);

        return map;
    }

}
